/*
 * Copyright (C) 2021 Baidu, Inc. All Rights Reserved.
 */
package com.chukun.rpc.protocol.protocol;

/**
 * <p>消息类型<p/>
 *
 * @author chukun
 * @version 1.0
 * @since 1.0-SNAPSHOT
 */
public enum  MessageType {

    REQUEST(0),
    RESPONSE(1),
    HEARTBEAT(2);

    private int type;

    MessageType(int type) {
        this.type = type;
    }

    public static MessageType getByType(int type) {
        for (MessageType messageType : MessageType.values()) {
            if (messageType.type == type) {
                return messageType;
            }
        }
        return null;
    }

    public int getType() {
        return type;
    }
}
